package system.mysql_connector;


import java.sql.Connection;
import java.sql.DriverManager;

import system.Sys_Config;

public class MySQL_Connector {
	
		
	public static void closeConnection(Connection connection){
		if(connection!=null){
			try {
				connection.close();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}		
	}
	
	public static Connection getConnection(){
		try {
			Class.forName("com.mysql.jdbc.Driver").newInstance();
			String connectURI = "jdbc:mysql://"+Sys_Config.DB_ADDRESS+":"+Sys_Config.DB_PORT+"/"+Sys_Config.DB_NAME+"?user="+
			Sys_Config.DB_USERNAME+"&password="+Sys_Config.DB_PWD+"&useUnicode=true&characterEncoding="+
			Sys_Config.DB_DEFAULT_ENCODING;
			Connection conn = DriverManager.getConnection(connectURI);
			return conn;
		}catch (Exception e){
			e.printStackTrace();
			return null;
		}		
	}
	
	
	
}
